<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <title>Title</title>
    <script src="/bootstrap/jquery-1.9.1.min.js"></script>
    <script src="/bootstrap/jquery.validate.min.js"></script>
    <script src="/bootstrap/validate.js"></script>
    <link rel="stylesheet" href="${ctx}/css/index_work.css">
</head>
<body>
<form action="${ctx}/login.do" method="post">
    用户名:<input type="text" name="name" required><br>
    密码:<input type="password" name="password" required><br>
    <input type="button" value="登录" onclick="login()">
</form>
</body>
<script>
    function login() {
        $("form").valid();

        $.post("${ctx}/login.do",$("form").serialize(),function (data) {
            if(data){
                alert("登录成功");
                location.href="${ctx}/list.do";
            }else{
                alert("密码错误提示");
            }
        })
    }
</script>
</html>
